package cn.tedu.review;

public class TestCar {
    public static void main(String[] args) {
        Car c = new Car();
        c.start();
        c.stop();
        System.out.println(c.getColor());
        BWM b = new BWM();
        b.start();
        b.stop();
        System.out.println(b.getColor());
        System.out.println(b.color);
        Car c2 = new TSL();
        c2.stop();
        c2.start();
        System.out.println(c2.getColor());
        Car c3 = new BWM();
        c3.start();
        c3.stop();
        c3.getColor();

    }
}
class Car {
    private String brand;
    private String color;
    private int id;
    private double price;

    public void start() {
        System.out.println("父类的开始方法");
    }

    public void stop() {
        System.out.println("父类的停止方法");
    }
    public Car(){
        System.out.println("无参构造");
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
class BWM extends Car{
    String color = "黑";
    @Override
    public void start(){
        System.out.println("子类BWM重写后的方法");
    }
}
class TSL extends Car{
    @Override
    public void stop(){
        System.out.println("子类TSL重写后的方法");
    }
    public void fly(){
        System.out.println("子类TSL独有的方法");
    }
}
